package com.bilicraft;
import java.io.*;
import java.awt.event.*;

import res.Resources;



public class MButtonStart extends MButton{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public Launcher launcher;
	public FileOps fileOps;
	
	public MButtonStart(String t, Resources rs, int x, int y){
		super(t,rs,x,y);
	}
	
	public MButtonStart(Launcher lc, String t, Resources rs, int x, int y){
		super(t,rs,x,y);
		launcher = lc;
		fileOps = lc.fileOps;
	}
	
	public void mClicked(MouseEvent e){
		fileOps.cmdName = launcher.username;
		fileOps.cmdXmx = "-Xmx"+launcher.memSize+"m ";
		if(launcher.d64)
			fileOps.cmdD64 = "-d64 ";
		else
			fileOps.cmdD64 = "";
		try{
			System.out.println("Starting...");
			if(fileOps.write(launcher.d64)){
				try{
					fileOps.run();
				}catch(Exception ex){
					System.err.println(ex.toString());
				}
			}
		}catch(IOException ie){
			System.err.println(ie.toString());
		}
		
	}
}
